
#include "Stack.h"

Stack::Stack(int capacity) {
    _top = 0;
    _capacity = capacity;
    _data = new int[_capacity];
}

Stack::~Stack() {
    free(_data);
    cout << "I'm used.\n";
}

void Stack::Push(int val) {
    _data[_top++] = val;
}

bool Stack::Empty() {
    return _top == 0;
}

int Stack::Top() {
    if (Empty()) {
        return -10086;
    }
    return _data[_top - 1];
}

int Stack::Pop() {
    if (Empty()) {
        return -10086;
    }
    int ret = _data[_top-- - 1];
    return ret;
}
